Optimal. Leaf size=460 \[ \frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}+\frac {(e+f x)^2 \cos (c+d x)}{b d}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^2}+\frac {2 i \sqrt {a^2-b^2} f^2 \text {Li}_3\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^3}-\frac {2 i \sqrt {a^2-b^2} f^2 \text {Li}_3\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^3}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.61, antiderivative size = 460, normalized size of antiderivative = 1.00, number of steps
used = 15, number of rules used = 10, integrand size = 28, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.357, Rules used = {4621, 32,
3377, 2718, 3404, 2296, 2221, 2611, 2320, 6724} \begin {gather*} \frac {2 i f^2 \sqrt {a^2-b^2} \text {PolyLog}\left (3,\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^3}-\frac {2 i f^2 \sqrt {a^2-b^2} \text {PolyLog}\left (3,\frac {i b e^{i (c+d x)}}{\sqrt {a^2-b^2}+a}\right )}{b^2 d^3}+\frac {2 f \sqrt {a^2-b^2} (e+f x) \text {PolyLog}\left (2,\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 f \sqrt {a^2-b^2} (e+f x) \text {PolyLog}\left (2,\frac {i b e^{i (c+d x)}}{\sqrt {a^2-b^2}+a}\right )}{b^2 d^2}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{\sqrt {a^2-b^2}+a}\right )}{b^2 d}+\frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}+\frac {(e+f x)^2 \cos (c+d x)}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 32
Rule 2221
Rule 2296
Rule 2320
Rule 2611
Rule 2718
Rule 3377
Rule 3404
Rule 4621
Rule 6724
Rubi steps
\begin {align*} \int \frac {(e+f x)^2 \cos ^2(c+d x)}{a+b \sin (c+d x)} \, dx &=\frac {a \int (e+f x)^2 \, dx}{b^2}-\frac {\int (e+f x)^2 \sin (c+d x) \, dx}{b}-\frac {\left (a^2-b^2\right ) \int \frac {(e+f x)^2}{a+b \sin (c+d x)} \, dx}{b^2}\\ &=\frac {a (e+f x)^3}{3 b^2 f}+\frac {(e+f x)^2 \cos (c+d x)}{b d}-\frac {\left (2 \left (a^2-b^2\right )\right ) \int \frac {e^{i (c+d x)} (e+f x)^2}{i b+2 a e^{i (c+d x)}-i b e^{2 i (c+d x)}} \, dx}{b^2}-\frac {(2 f) \int (e+f x) \cos (c+d x) \, dx}{b d}\\ &=\frac {a (e+f x)^3}{3 b^2 f}+\frac {(e+f x)^2 \cos (c+d x)}{b d}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}+\frac {\left (2 i \sqrt {a^2-b^2}\right ) \int \frac {e^{i (c+d x)} (e+f x)^2}{2 a-2 \sqrt {a^2-b^2}-2 i b e^{i (c+d x)}} \, dx}{b}-\frac {\left (2 i \sqrt {a^2-b^2}\right ) \int \frac {e^{i (c+d x)} (e+f x)^2}{2 a+2 \sqrt {a^2-b^2}-2 i b e^{i (c+d x)}} \, dx}{b}+\frac {\left (2 f^2\right ) \int \sin (c+d x) \, dx}{b d^2}\\ &=\frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}+\frac {(e+f x)^2 \cos (c+d x)}{b d}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}-\frac {\left (2 i \sqrt {a^2-b^2} f\right ) \int (e+f x) \log \left (1-\frac {2 i b e^{i (c+d x)}}{2 a-2 \sqrt {a^2-b^2}}\right ) \, dx}{b^2 d}+\frac {\left (2 i \sqrt {a^2-b^2} f\right ) \int (e+f x) \log \left (1-\frac {2 i b e^{i (c+d x)}}{2 a+2 \sqrt {a^2-b^2}}\right ) \, dx}{b^2 d}\\ &=\frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}+\frac {(e+f x)^2 \cos (c+d x)}{b d}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}-\frac {\left (2 \sqrt {a^2-b^2} f^2\right ) \int \text {Li}_2\left (\frac {2 i b e^{i (c+d x)}}{2 a-2 \sqrt {a^2-b^2}}\right ) \, dx}{b^2 d^2}+\frac {\left (2 \sqrt {a^2-b^2} f^2\right ) \int \text {Li}_2\left (\frac {2 i b e^{i (c+d x)}}{2 a+2 \sqrt {a^2-b^2}}\right ) \, dx}{b^2 d^2}\\ &=\frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}+\frac {(e+f x)^2 \cos (c+d x)}{b d}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}+\frac {\left (2 i \sqrt {a^2-b^2} f^2\right ) \text {Subst}\left (\int \frac {\text {Li}_2\left (\frac {i b x}{a-\sqrt {a^2-b^2}}\right )}{x} \, dx,x,e^{i (c+d x)}\right )}{b^2 d^3}-\frac {\left (2 i \sqrt {a^2-b^2} f^2\right ) \text {Subst}\left (\int \frac {\text {Li}_2\left (\frac {i b x}{a+\sqrt {a^2-b^2}}\right )}{x} \, dx,x,e^{i (c+d x)}\right )}{b^2 d^3}\\ &=\frac {a (e+f x)^3}{3 b^2 f}-\frac {2 f^2 \cos (c+d x)}{b d^3}+\frac {(e+f x)^2 \cos (c+d x)}{b d}+\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d}-\frac {i \sqrt {a^2-b^2} (e+f x)^2 \log \left (1-\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^2}-\frac {2 \sqrt {a^2-b^2} f (e+f x) \text {Li}_2\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^2}+\frac {2 i \sqrt {a^2-b^2} f^2 \text {Li}_3\left (\frac {i b e^{i (c+d x)}}{a-\sqrt {a^2-b^2}}\right )}{b^2 d^3}-\frac {2 i \sqrt {a^2-b^2} f^2 \text {Li}_3\left (\frac {i b e^{i (c+d x)}}{a+\sqrt {a^2-b^2}}\right )}{b^2 d^3}-\frac {2 f (e+f x) \sin (c+d x)}{b d^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 2.65, size = 782, normalized size = 1.70 \begin {gather*} \frac {a x \left (3 e^2+3 e f x+f^2 x^2\right )-\frac {3 i \sqrt {a^2-b^2} \left (-i \left (d^2 \left (\sqrt {a^2-b^2} f x (2 e+f x) \left (-\log \left (1+\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}-a \sin (c)}\right )+\log \left (1-\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{-i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}+a \sin (c)}\right )\right ) (\cos (c)+i \sin (c))+2 e^2 \tan ^{-1}\left (\frac {b \cos (c+d x)+i (a+b \sin (c+d x))}{\sqrt {a^2-b^2}}\right ) \sqrt {-\left (\left (a^2-b^2\right ) (\cos (c)+i \sin (c))^2\right )}\right )-2 \sqrt {a^2-b^2} f^2 \text {Li}_3\left (-\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}-a \sin (c)}\right ) (\cos (c)+i \sin (c))+2 \sqrt {a^2-b^2} f^2 \text {Li}_3\left (\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{-i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}+a \sin (c)}\right ) (\cos (c)+i \sin (c))\right )+2 \sqrt {a^2-b^2} d f (e+f x) \text {Li}_2\left (-\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}-a \sin (c)}\right ) (\cos (c)+i \sin (c))-2 \sqrt {a^2-b^2} d f (e+f x) \text {Li}_2\left (\frac {b (\cos (2 c+d x)+i \sin (2 c+d x))}{-i a \cos (c)+\sqrt {\left (-a^2+b^2\right ) (\cos (c)+i \sin (c))^2}+a \sin (c)}\right ) (\cos (c)+i \sin (c))\right )}{d^3 \sqrt {-\left (\left (a^2-b^2\right ) (\cos (c)+i \sin (c))^2\right )}}+\frac {3 b \cos (d x) \left (\left (-2 f^2+d^2 (e+f x)^2\right ) \cos (c)-2 d f (e+f x) \sin (c)\right )}{d^3}-\frac {3 b \left (2 d f (e+f x) \cos (c)+\left (-2 f^2+d^2 (e+f x)^2\right ) \sin (c)\right ) \sin (d x)}{d^3}}{3 b^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.25, size = 0, normalized size = 0.00 \[\int \frac {\left (f x +e \right )^{2} \left (\cos ^{2}\left (d x +c \right )\right )}{a +b \sin \left (d x +c \right )}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 1645 vs. \(2 (407) = 814\).
time = 0.55, size = 1645, normalized size = 3.58 \begin {gather*} \frac {2 \, a d^{3} f^{2} x^{3} + 6 \, a d^{3} f x^{2} e + 6 \, a d^{3} x e^{2} - 6 \, b f^{2} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm polylog}\left (3, -\frac {i \, a \cos \left (d x + c\right ) + a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}}}{b}\right ) + 6 \, b f^{2} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm polylog}\left (3, -\frac {i \, a \cos \left (d x + c\right ) + a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}}}{b}\right ) - 6 \, b f^{2} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm polylog}\left (3, -\frac {-i \, a \cos \left (d x + c\right ) + a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}}}{b}\right ) + 6 \, b f^{2} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm polylog}\left (3, -\frac {-i \, a \cos \left (d x + c\right ) + a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}}}{b}\right ) - 6 \, {\left (i \, b d f^{2} x + i \, b d f e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm Li}_2\left (\frac {i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b} + 1\right ) - 6 \, {\left (-i \, b d f^{2} x - i \, b d f e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm Li}_2\left (\frac {i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b} + 1\right ) - 6 \, {\left (-i \, b d f^{2} x - i \, b d f e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm Li}_2\left (\frac {-i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b} + 1\right ) - 6 \, {\left (i \, b d f^{2} x + i \, b d f e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} {\rm Li}_2\left (\frac {-i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b} + 1\right ) - 3 \, {\left (b c^{2} f^{2} - 2 \, b c d f e + b d^{2} e^{2}\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (2 \, b \cos \left (d x + c\right ) + 2 i \, b \sin \left (d x + c\right ) + 2 \, b \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} + 2 i \, a\right ) - 3 \, {\left (b c^{2} f^{2} - 2 \, b c d f e + b d^{2} e^{2}\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (2 \, b \cos \left (d x + c\right ) - 2 i \, b \sin \left (d x + c\right ) + 2 \, b \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - 2 i \, a\right ) + 3 \, {\left (b c^{2} f^{2} - 2 \, b c d f e + b d^{2} e^{2}\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-2 \, b \cos \left (d x + c\right ) + 2 i \, b \sin \left (d x + c\right ) + 2 \, b \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} + 2 i \, a\right ) + 3 \, {\left (b c^{2} f^{2} - 2 \, b c d f e + b d^{2} e^{2}\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-2 \, b \cos \left (d x + c\right ) - 2 i \, b \sin \left (d x + c\right ) + 2 \, b \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - 2 i \, a\right ) + 3 \, {\left (b d^{2} f^{2} x^{2} - b c^{2} f^{2} + 2 \, {\left (b d^{2} f x + b c d f\right )} e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-\frac {i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b}\right ) - 3 \, {\left (b d^{2} f^{2} x^{2} - b c^{2} f^{2} + 2 \, {\left (b d^{2} f x + b c d f\right )} e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-\frac {i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) + i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b}\right ) + 3 \, {\left (b d^{2} f^{2} x^{2} - b c^{2} f^{2} + 2 \, {\left (b d^{2} f x + b c d f\right )} e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-\frac {-i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) + {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b}\right ) - 3 \, {\left (b d^{2} f^{2} x^{2} - b c^{2} f^{2} + 2 \, {\left (b d^{2} f x + b c d f\right )} e\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} \log \left (-\frac {-i \, a \cos \left (d x + c\right ) - a \sin \left (d x + c\right ) - {\left (b \cos \left (d x + c\right ) - i \, b \sin \left (d x + c\right )\right )} \sqrt {-\frac {a^{2} - b^{2}}{b^{2}}} - b}{b}\right ) + 6 \, {\left (b d^{2} f^{2} x^{2} + 2 \, b d^{2} f x e + b d^{2} e^{2} - 2 \, b f^{2}\right )} \cos \left (d x + c\right ) - 12 \, {\left (b d f^{2} x + b d f e\right )} \sin \left (d x + c\right )}{6 \, b^{2} d^{3}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] Timed out
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Timed out} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F(-1)]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \text {Hanged} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________